<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>我的快递</title>
<%@ include file="/pages/wx/baseHead.jsp"%>
<!-- #cb60b3 -->
</head>
<body>

<form action="${urlBasePath }weixin/user/expressMySend.do" id="theform" name="theform" method="post">
<div class="bd" style="height: 100%;width: 100%; position: fixed;">
    <div class="weui_tab" id="jikd">
        <div class="weui_navbar" style="z-index: 20" id="jikd2">
            <div class="weui_navbar_item weui_bar_item_on" 
            	onclick="toDiv('jikd');" style="color: #ffffff;background-color: #04BE02;">
                	已寄快递
            </div>
            <div class="weui_navbar_item" 
            	onclick="toDiv('shoukd');" >
               		收快递
            </div>
        </div>
        <div class="weui_tab_bd" id="jikd3" style="display: none;"> 
			<div class="weui_panel weui_panel_access">
			      <div class="weui_panel_bd" style="margin-top: -4px;">
			        <c:forEach var="obj" items="${objsSend.data }" >
			            <div class="weui_media_box weui_media_appmsg form-inline">
			                <div class="weui_media_bd" >
			                    <h4 class="weui_media_title" style="width: 100%;" onclick="to('${urlBasePath}weixin/user/expressDetail.do?sn=${obj.sn }');">收件人：${obj.directionName }      
			                    	<div style="float: right;font-size: .8em;">
									     <i class="fa fa-calendar fa-fw"></i><fmt:formatDate value="${obj.createTm}" pattern="yyyy-MM-dd"/>
									</div>
			                    </h4>
			                    <p class="weui_media_desc">
			                    	收件电话：
			                    	<span style="width: 60%">${obj.directionPhone }</span>
			                    </p>
			                    <p class="weui_media_desc">
			                    	快递费用：<fmt:formatNumber value="${obj.amount }" pattern="#,##0.00"/>元
			                    	<c:if test="${obj.forPublic == '01' }"><span style="color: #00CD00;"><i class="fa fa-product-hunt fa-fw"></i>对公</c:if>
			                    </p>
			                    <p class="weui_media_desc">
			                    	收件地址：
			                    	<span style="width: 60%">${obj.directionAddress }</span>
			                    </p>
			                    <p class="weui_media_desc">
			                    	揽件地址：
			                    	<span style="width: 60%">${obj.fromOperName }</span>
			                    </p>
			                    <c:if test="${obj.expressNo != null }">
					                <p class="weui_media_desc">快递单号：
					                		<font>${obj.expressNo }
						                    		<a href="http://m.kuaidi100.com/index_all.html?type=${obj.expressCode }&postid=${obj.expressNo }" style="color: red;"> &nbsp;配送查询</a>
					                    	</font>
					                </p>
				                </c:if>
			                </div>
			                
										
					        <div align="right" style="width: 60px;">
			                	<c:forEach var="state" items="${states }">
				                	<c:if test="${state.value == obj.state }">
						                    	${state.text }
				                  	 </c:if>
				                </c:forEach>
				                <c:if test="${obj.payState == '00' }"><div style="color: #04BE02;">已支付</div></c:if>
				                <div style="display: block;padding-top: 6px;"></div>
				                <c:if test="${(obj.state == '01' || obj.state == '02') && obj.payState != '00' }">
				                	<button type="button" onclick="cancel('${obj.sn}','${urlBasePath }weixin/user/expressMySend.do');"  class="weui_btn weui_btn_plain_primary weui_btn_mini">
						                    	撤单
						            </button>
				                </c:if>
				                <c:if test="${obj.amount > 0 && obj.forPublic == '02' && obj.payState != '00' }">
				                	<button type="button" onclick="goPayReady('${obj.sn}');"  class="weui_btn weui_btn_plain_primary weui_btn_mini">
						                    	支付
						            </button>
				                </c:if>
					         </div>
			            </div>
		        	</c:forEach>
		        	<c:if test="${fn:length(objsSend.data) == 0}">
				    	<div align="center" style="color: red;padding: 10px 0 20px 0px;">无数据</div>
				    </c:if>
			     </div>
		    </div>
			<nav style="text-align: center;">
			  <ul class="pagination">
			    <li>
			      <a href="javascript:void(0);" onclick="goPage(1,'${urlBasePath }weixin/user/expressMySend.do');" aria-label="Previous">
			        <span aria-hidden="true">&laquo;</span>
			      </a>
			    </li>
			    <li><a href="javascript:void(0);" onclick="goPageNew('${objsSend.currentPage-1}','${urlBasePath }weixin/user/expressMySend.do');"><span aria-hidden="true">&lt;</span></a></li>
			    <li><a href="javascript:void(0);">${objsSend.currentPage}/${objsSend.maxPage<1?1:objsSend.maxPage}</a></li>
			    <li><a href="javascript:void(0);" onclick="goPageNew('${objsSend.currentPage+1}','${urlBasePath }weixin/user/expressMySend.do');"><span aria-hidden="true">&gt;</span></a></li>
			    <li>
			      <a href="javascript:void(0);" onclick="goPageNew('${objsSend.maxPage}','${urlBasePath }weixin/user/expressMySend.do');" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
			  </ul>
			</nav>
			
			<input type="hidden" name="pageNumber" id="pageNumber" value="${objsSend.currentPage==null?0:objsSend.currentPage }">
			<input type="hidden" id="maxPage" value="${objsSend.maxPage==null?0:objsSend.maxPage }">
			<div style="height: 40px;display: block;"></div>
        </div>
    </div>
	<div class="weui_tab" id="shoukd">
	        <div class="weui_navbar" id="shoukd2" style="display: none;">
	            <div class="weui_navbar_item " onclick="toDiv('jikd');" >
	                	已寄快递
	            </div>
	            <div class="weui_navbar_item weui_bar_item_on" onclick="toDiv('shoukd');"
	            	style="color: #ffffff;background-color: #04BE02;">
	               		收快递
	            </div>
	        </div>
	        <div class="weui_tab_bd" id="shoukd3" style="display: none;">
				<div class="weui_panel weui_panel_access" style="margin-top: -4px;">
				      <div class="weui_panel_bd">
				      
				        <c:forEach var="obj" items="${objsReceive.data }" >
				        	<c:if test="${obj.type == '1' }">
					            <div class="weui_media_box weui_media_appmsg form-inline">
					                <div class="weui_media_bd">
					                    <h4 class="weui_media_title" style="width: 100%;" onclick="to('${urlBasePath}weixin/toExpressReceive.do?sn=${obj.sn }');">寄件人：${obj.fromName }      
					                    	<div style="float: right;font-size: .8em;">
											     <i class="fa fa-calendar fa-fw"></i><fmt:formatDate value="${obj.createTm}" pattern="yyyy-MM-dd"/>
											</div>
					                    </h4>
					                    <%-- <p class="weui_media_desc"><i class="fa fa-th-list fa-fw"></i>订单号：${obj.sn }</p> --%>
					                     <p class="weui_media_desc">
					                    	签收状态：
					                    	<span style="width: 60%" id="state${obj.type }${obj.sn}">
					                    		<c:forEach var="state" items="${states }">
								                	<c:if test="${state.value == obj.state }">
										                    	${state.text }
								                  	 </c:if>
								                </c:forEach>
					                    	</span>
					                    </p>
					                     <p class="weui_media_desc">
					                    	寄件电话：
					                    	<span style="width: 60%">${obj.fromPhone }</span>
					                    </p>
					                    <p class="weui_media_desc">快递单号：<font id="expcodeFont">${obj.expressNo }
					                    	<c:if test="${obj.expressNo != null }">
					                    		<a onclick="to('http://m.kuaidi100.com/index_all.html?type=${obj.expressCode }&postid=${obj.expressNo }');" style="color: red;"> &nbsp;配送查询</a>
					                    	</c:if>
					                    	</font>
					                    </p>
					                </div>
					                
												
							        <div align="right" style="width: 60px;">
						                <div style="display: block;padding-top: 6px;"></div>
						                <c:if test="${obj.state == '03' || obj.state == '04'}">
						                	<button type="button" id="btn${obj.type }${obj.sn }" onclick="dilivery('${obj.sn}','${obj.type }');"  class="weui_btn weui_btn_plain_primary weui_btn_mini">
								                    	签收
								            </button>
						                </c:if>
							         </div>
					            </div>
				        	</c:if>
				        	<c:if test="${obj.type == '2' }">
				        		<div class="weui_media_box weui_media_appmsg form-inline">
					                <div class="weui_media_bd">
					                    <h4 class="weui_media_title" style="width: 100%;">收件通知      
					                    	<div style="float: right;font-size: .8em;">
											     <i class="fa fa-calendar fa-fw"></i><fmt:formatDate value="${obj.createTm}" pattern="yyyy-MM-dd"/>
											</div>
					                    </h4>
					                    <p class="weui_media_desc">
					                    	签收状态：
					                    	<span style="width: 60%;" id="state${obj.type }${obj.sn}">
					                    		<c:choose>
									        		<c:when test="${obj.pickState == '01' }">已签收</c:when>
									        		<c:otherwise>未签收</c:otherwise>
									        	</c:choose>
					                    	</span>
					                    </p>
					                     <p class="weui_media_desc">
					                    	提取码：
					                    	<span style="width: 60%;color: red;">${obj.pickCode }</span>
					                    </p>
					                    <p class="weui_media_desc">
					                    	取件地址：
					                    	<span style="width: 60%">${obj.address }</span>
					                    </p>
					                </div>
					                
												
							        <div align="right" style="width: 60px;">
							        	<c:choose>
							        		<c:when test="${obj.pickState == '01' }"></c:when>
							        		<c:otherwise>
								                <div style="display: block;padding-top: 6px;"></div>
												<button type="button" id="btn${obj.type }${obj.sn }" onclick="dilivery('${obj.sn}','${obj.type }');"  class="weui_btn weui_btn_plain_primary weui_btn_mini">
									                    	签收
									            </button>							        		
							        		</c:otherwise>
							        	</c:choose>
						                	
							         </div>
					            </div>
				        	</c:if>
			        	</c:forEach>
			        	<c:if test="${fn:length(objsReceive.data) == 0}">
					    	<div align="center" style="color: red;padding: 10px 0 20px 0px;">无数据</div>
					    </c:if>
				     </div>
			    </div>
				<nav style="text-align: center;">
				  <ul class="pagination">
				    <li>
				      <a href="javascript:void(0);" onclick="goPageNew(1,'${urlBasePath }weixin/user/expressMyReceive.do');" aria-label="Previous">
				        <span aria-hidden="true">&laquo;</span>
				      </a>
				    </li>
				    <li><a href="javascript:void(0);" onclick="goPageNew('${objsReceive.currentPage-1}','${urlBasePath }weixin/user/expressMyReceive.do');"><span aria-hidden="true">&lt;</span></a></li>
				    <li><a href="javascript:void(0);">${objsReceive.currentPage}/${objsReceive.maxPage<1?1:objsReceive.maxPage}</a></li>
				    <li><a href="javascript:void(0);" onclick="goPageNew('${objsReceive.currentPage+1}','${urlBasePath }weixin/user/expressMyReceive.do');"><span aria-hidden="true">&gt;</span></a></li>
				    <li>
				      <a href="javascript:void(0);" onclick="goPageNew('${objsReceive.maxPage}','${urlBasePath }weixin/user/expressMyReceive.do');" aria-label="Next">
				        <span aria-hidden="true">&raquo;</span>
				      </a>
				    </li>
				  </ul>
				</nav>
				<input type="hidden" name="pageNumber2" id="pageNumber2" value="${objsReceive.currentPage==null?0:objsReceive.currentPage }">
				<input type="hidden" id="maxPage2" value="${objsReceive.maxPage==null?0:objsReceive.maxPage }">
				<div style="height: 40px;display: block;"></div>
	        </div>
	    </div>   
	    </div> 
  </form>   




<div class="weui_tabbar" style="position: fixed;bottom: 0%;left: 0%;background-color:#04BE02;">
    <a href="${urlBasePath}weixin/user/expressSend.do" class="weui_tabbar_item weui_bar_item_on">
        <p class="weui_tabbar_label" style="line-height: 40px;font-size:1.2em;color: #ffffff;">
        	寄快递</p>
    </a>
</div>
<div style="height: 60px;display: block;"></div>

<div class="pop">
    <i class="fa fa-home fa-lg popi"></i>
</div>
<!-- 引入微信样式代码提示工具开始 -->
<%@ include file="/pages/wx/wxClass.jsp"%>
<!-- 引入微信样式代码提示工具结束 -->
<%@ include file="/pages/wx/baseBottom.jsp"%>
</body>
<script type="text/javascript">
	
	
	$(function(){
	});
	
	function cancel(sn)
	{
		var url = '${urlBasePath}weixin/user/expressCancel.do';
		confirm('提示信息','您确定要撤消此单吗？',function(){
			$.ajax({
				url:url,
				async:true,
				data:
				{
					'v':(new Date()).valueOf(),
					'sn':sn
				},
				success:function(ret){
					debugger;
					if(ret.code == '0'){
						openToast(ret.msg);
						
						setTimeout(function(){
							goPage(1,'${urlBasePath }weixin/user/expressMySend.do');
						},1000);
					}else{
						openDia('提示信息',ret.msg);
					}
				},
				error:function(){
					alert('调用失败');	
				}
			});
		});
	}
	function goPageNew(page,url){
		if(url.indexOf("expressMySend")!=-1){
			if(null == page || page == '')
			{
				page = 1;
			}
			if(page<0) page = 1;
			var maxPage =$("#maxPage").val();
			if(page > maxPage ) page = maxPage;
			$("#pageNumber").val(page);	
		}else{
			if(null == page || page == '')
			{
				page = 1;
			}
			if(page<0) page = 1;
			var maxPage =$("#maxPage2").val();
			if(page > maxPage ) page = maxPage;
			$("#pageNumber2").val(page);
		}
		
		//alert(url);
		$("#theform").attr("action",url);
		$("#theform").submit();
	}
	function toDiv(divTag){
		$("#jikd").hide();
		$("#shoukd").hide();
		$("#jikd2").hide();
		$("#shoukd2").hide();	
		$("#jikd3").hide();
		$("#shoukd3").hide();	
		if(divTag=='jikd'||divTag=='shoukd'){
			$("#"+divTag).show();	
			$("#"+divTag+"2").show();
			$("#"+divTag+"3").show();			
		}else{
			$("#jikd").show();
			$("#jikd2").show();
			$("#jikd3").show();
		}
	}
	toDiv('${flag}');
	
	/*签收*/
	function dilivery(sn,type)
	{
		var url = "";
		if(type == '1')
		{
			url = '${urlBasePath}weixin/expressReceive.do';
		}else if(type == '2')
		{
			url = '${urlBasePath}weixin/user/expressPick.do';
		}
		confirm('提示','确定签收？',function(){
			$.ajax({
				url:url,
				async:true,
				data:{
					sn:sn
				},
				success:function(ret){
					if(ret.code == '0')
					{
						openToast('操作成功');
						var adr1 = '#state'+type+sn;
						var adr2 = '#btn'+type+sn;
						$(adr1).html("已签收");
						hide(adr2);
					}else
					{
						openDia('提示',ret.msg);
					}
				},
				error:function(){
					alert('系统错误');
				}
			});
			
		});
	}	
</script>
</html>

